<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListResponsavelTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <p:growl id="messages" life="3000" />

            <h:panelGroup id="messagePanel" styleClass="ajustaListaMensagemErro"  layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="list"/>
            </h:panelGroup>

            <h:panelGroup >

                <p:dataTable id="tbl" value="#{responsavelController.lista}" var="item"  paginator="true" rows="#{bundle.rows}" pageLinks="5" widgetVar="responsavelTable"
                             currentPageReportTemplate="#{bundle.currentPageReportTemplateResponsavel}"  paginatorTemplate="#{bundle.paginatorTemplate}"
                             rowsPerPageTemplate="#{bundle.rowsPerPageTemplate}"  paginatorPosition="#{bundle.paginatorPosition}" emptyMessage="#{bundle.ListResponsavelEmpty}" rowKey="#{item.rspId}" selection="#{responsavelController.selectedResponsavel}" selectionMode="single">

                    <f:facet id="global" name="header">
                        <p:outputPanel id="test" >
                            <h:outputText value="#{bundle.searchAllFields}" />
                            <p:inputText id="globalFilter" onkeyup="responsavelTable.filter()" style="width: 200px;" >
                                <p:focus for="globalFilter" />
                            </p:inputText>
                        </p:outputPanel>
                    </f:facet>

                    <p:column styleClass="firstColumn" filterBy="#{item.rspId}" sortBy="#{item.rspId}" filterMatchMode="contains">
                        <f:facet name="header">
                            <h:outputText styleClass="cabecalhoNegrito" value="#{bundle.ListResponsavelTitle_rspId}"/>
                        </f:facet>
                        <h:outputText value="#{item.rspId}"/>
                    </p:column>
                    <p:column filterBy="#{item.rspNm}" sortBy="#{item.rspNm}" filterMatchMode="contains">
                        <f:facet name="header">
                            <h:outputText styleClass="cabecalhoNegrito" value="#{bundle.ListResponsavelTitle_rspNm}"/>
                        </f:facet>
                        <h:outputText value="#{item.rspNm}"/>
                    </p:column>
                    <p:column filterBy="#{item.rspDesc}" sortBy="#{item.rspDesc}" filterMatchMode="contains">
                        <f:facet name="header">
                            <h:outputText styleClass="cabecalhoNegrito" value="#{bundle.ListResponsavelTitle_rspDesc}"/>
                        </f:facet>
                        <h:outputText value="#{item.rspDesc}"/>
                    </p:column>
                    <p:column filterBy="#{item.rspEmail}" sortBy="#{item.rspEmail}" filterMatchMode="contains">
                        <f:facet name="header">
                            <h:outputText styleClass="cabecalhoNegrito" value="#{bundle.ListResponsavelTitle_rspEmail}"/>
                        </f:facet>
                        <h:outputText value="#{item.rspEmail}"/>
                    </p:column>
                    <p:column filterBy="#{item.rspCrgId.crgNm}" sortBy="#{item.rspCrgId.crgNm}" filterMatchMode="contains">
                        <f:facet name="header">
                            <h:outputText styleClass="cabecalhoNegrito" value="#{bundle.ListResponsavelTitle_rspCrgId}"/>
                        </f:facet>
                        <h:outputText value="#{item.rspCrgId.crgNm}"/>
                    </p:column>
                    <p:column styleClass="columnTipo" filterBy="#{item.rspAreId.areNm}" sortBy="#{item.rspAreId.areNm}" filterMatchMode="contains">
                        <f:facet name="header">
                            <h:outputText styleClass="cabecalhoNegrito" value="#{bundle.ListResponsavelTitle_rspAreId}"/>
                        </f:facet>
                        <h:outputText value="#{item.rspAreId.areNm}"/>
                    </p:column>

                    <p:column style="width:3%" exportable="false">
                        <div class="cabecalho">
                            <div class="imagem">
                                <p:commandLink update=":formList:displayView" oncomplete="responsavelDialogView.show()" actionListener="#{responsavelController.prepareView}" onerror="responsavelDialogView.hide();" title="#{bundle.MsgVisualizar}" styleClass="ui-icon ui-icon-search">
                                    <f:setPropertyActionListener value="#{item}" 
                                                                 target="#{responsavelController.selectedResponsavel}" />
                                </p:commandLink>
                            </div>                 
                            <div class="titulo">
                                <p:commandLink ajax="false"  action="#{responsavelController.prepareEdit}" rendered="#{!autenticadorController.loginVisualizador}" title="#{bundle.ListAreaEditLink}" styleClass="ui-icon ui-icon-pencil" >
                                    <f:setPropertyActionListener value="#{item}" 
                                                                 target="#{responsavelController.selectedResponsavel}" />
                                </p:commandLink>
                            </div>
                        </div>                     
                    </p:column>

                    <f:facet name="footer">                            
                        <p:commandButton id="createCommand" rendered="#{!autenticadorController.loginVisualizador}" ajax="false" icon="ui-icon-document" action="#{responsavelController.prepareCreate}" value="#{bundle.ListResponsavelCreateLink}"/>
                        <p:commandButton id="viewCommand"  value="#{bundle.MsgVisualizar}" icon="ui-icon-search"  update=":formList:displayView" oncomplete="responsavelDialogView.show()" actionListener="#{responsavelController.prepareView}" />
                        <p:commandButton id="editCommand" ajax="false" action="#{responsavelController.prepareEdit}" value="#{bundle.ListResponsavelEditLink}" icon="ui-icon-pencil" />
                        <p:commandButton id="deleteCommand" ajax="false" rendered="#{autenticadorController.loginAdmin}" onclick="confirmationDestroy.show();" value="#{bundle.ListResponsavelDestroyLink}" type="button" icon="ui-icon-trash" />

                        <p:commandButton id="excelExportAll" ajax="false" value="#{bundle.excelExportAll}" icon="ui-icon-script">
                            <p:dataExporter type="xls" target="tbl" fileName="#{bundle.excelExportAllFileName_Responsavel}" postProcessor="#{responsavelController.postProcessorXLS}"/>
                        </p:commandButton>
                        <p:commandButton id="excelExportPagAtual" ajax="false" value="#{bundle.excelExportPagAtual}" icon="ui-icon-calculator">
                            <p:dataExporter type="xls" target="tbl" fileName="#{bundle.excelExportPagAtualFileName_Responsavel}" pageOnly="true" postProcessor="#{responsavelController.postProcessorXLS}"/>
                        </p:commandButton>
                    </f:facet>

                </p:dataTable>
                <p:confirmDialog id="confirmDestroy" message="#{bundle.MsgConfirmDestroy_message}" header="#{bundle.MsgConfirmDestroy_header}" severity="alert" widgetVar="confirmationDestroy">
                    <p:commandButton id="confirm" ajax="false" value="#{bundle.MsgDialog_confirmar}"  oncomplete="confirmationDestroy.hide(); #{responsavelController.prepareList}" action="#{responsavelController.destroy}" />
                    <p:commandButton id="decline"  value="#{bundle.MsgDialog_cancelar}" update="messages" onclick="confirmationDestroy.hide();" type="button"/>

                </p:confirmDialog>

                <p:dialog id="dialogView" header="#{bundle.ResponsavelDialogView_header}" widgetVar="responsavelDialogView" resizable="false"
                          width="500" >

                    <h:panelGrid id="displayView" columns="2" cellpadding="4">                          

                        <h:outputText value="#{bundle.ViewResponsavelLabel_rspId}"/>
                        <h:outputText value="#{responsavelController.selected.rspId}" title="#{bundle.ViewResponsavelTitle_rspId}"/>
                        <h:outputText value="#{bundle.ViewResponsavelLabel_rspNm}"/>
                        <h:outputText value="#{responsavelController.selected.rspNm}" title="#{bundle.ViewResponsavelTitle_rspNm}"/>
                        <h:outputText value="#{bundle.ViewResponsavelLabel_rspDesc}"/>
                        <h:outputText value="#{responsavelController.selected.rspDesc}" title="#{bundle.ViewResponsavelTitle_rspDesc}"/>
                        <h:outputText value="#{bundle.ViewResponsavelLabel_rspEmail}"/>
                        <h:outputText value="#{responsavelController.selected.rspEmail}" title="#{bundle.ViewResponsavelTitle_rspEmail}"/>
                        <h:outputText value="#{bundle.ViewResponsavelLabel_rspCrgId}"/>
                        <h:outputText value="#{responsavelController.selected.rspCrgId.crgNm}" title="#{bundle.ViewResponsavelTitle_rspCrgId}"/>
                        <h:outputText value="#{bundle.ViewResponsavelLabel_rspAreId}"/>
                        <h:outputText value="#{responsavelController.selected.rspAreId.areNm}" title="#{bundle.ViewResponsavelTitle_rspAreId}"/>

                        <h:outputLabel value="#{bundle.createBy}" for="nomeCriador" rendered="#{not empty responsavelController.criacaoHist.nomeUsuario}"/>
                        <h:outputText id="nomeCriador" value="#{responsavelController.criacaoHist.nomeUsuario}" rendered="#{not empty responsavelController.criacaoHist.nomeUsuario}"/>
                        <h:outputLabel value="#{bundle.createDate}" for="dataCriacao" rendered="#{not empty responsavelController.criacaoHist.dataHora}"/>
                        <h:outputText id="dataCriacao" value="#{responsavelController.criacaoHist.dataHora}" rendered="#{not empty responsavelController.criacaoHist.dataHora}"/>     
                        <h:outputLabel value="#{bundle.updateBy}" for="nomeAlterador" rendered="#{not empty responsavelController.alteracaoHist.nomeUsuario}"/>
                        <h:outputText id="nomeAlterador" value="#{responsavelController.alteracaoHist.nomeUsuario}" rendered="#{not empty responsavelController.alteracaoHist.nomeUsuario}"/>
                        <h:outputLabel value="#{bundle.updateDate}" for="dataAlteracao" rendered="#{not empty responsavelController.alteracaoHist.dataHora}"/>
                        <h:outputText id="dataAlteracao" value="#{responsavelController.alteracaoHist.dataHora}" rendered="#{not empty responsavelController.alteracaoHist.dataHora}" /> 

                    </h:panelGrid>
                </p:dialog>
            </h:panelGroup>              
            <!--</h:form>-->
        </ui:define>
    </ui:composition>

</html>
